import java.util.ArrayList;

public class Inventory extends AbstractSubject
{

	private static ArrayList<Items> items=new ArrayList<Items>();

	public Inventory()
	{
		items = new ArrayList<Items>();
	}
	public void addItems(Items i)
	{
		items.add(i);
	}
	public static boolean returnItem(int itemID)
	{
		for(int i=0; i<items.size(); i++)
		{
			if(items.get(i).returnItem(itemID))
				return true;
		}
		System.out.println("Return item failed.");
		return false;
	}
	public static Items returnItems(Item searchItem)
	{
		ArrayList<Item> i = new ArrayList<Item>();
		Items returning = null;
		for(int j=0;j<items.size();j++)
		{
			returning = items.get(j);
			i = returning.getItemList();
			for(int t=0;t<i.size();t++)
			{
				if(i.get(t).equals(searchItem))
				{
					return returning; 
				}
			}
		}
		return returning;
	}

	public static ArrayList<Items> getPurchasableItems()
	{
		ArrayList<Items> list = new ArrayList<Items>();
		for (int i = 0; i < items.size(); i++)
		{
			if (items.get(i) instanceof Purchaseable)
			{
				list.add(items.get(i));
			}
		}
		return list;
	}

	public static ArrayList<Items> getBorrowableItems()
	{
		ArrayList<Items> list = new ArrayList<Items>();
		for (int i = 0; i < items.size(); i++)
		{
			if (items.get(i) instanceof Borrowable)
			{
				list.add(items.get(i));
			}
		}
		return list;
	}

	public static ArrayList<Items> getItems() {
		return items;
	}
	
	public static ArrayList<Items> getInventory()
	{
		return items;
	}
	
}
